import { options } from './defaults'
import { models } from './model'
import { store, createStore, replaceReducer } from './store'

let started = false;

export default function defaultStore() {
  const { initialState, middlewares, reducers, enhancers } = options;

  if (started) {
    replaceReducer(store, models, reducers);
  } else {
    createStore(models, reducers, initialState, middlewares, enhancers);
  }
  started = true;
  return store;
}
